package com.yfy.model.mapper;

import com.yfy.model.entity.Article;
import com.yfy.model.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author yfy2001
 * @date 2022/11/15 22:27
 */
@Mapper
public interface UserMapper {
    /**
     * 新增用户
     * @param user
     * @return
     */
    @Insert("INSERT INTO t_user (creator,modifier,gmt_created,gmt_modified,is_deleted,username,password,email,valid)" +
            " VALUES (#{creator}, #{modifier},#{gmtCreated},#{gmtModified},#{isDeleted},#{username},#{password}, #{email}, #{valid})")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    public Integer addUser(User user);

    /**
     * 查询用户列表
     * @return
     */
    @Select("SELECT * FROM t_user")
    public List<User> selectUserWithPage();

    /**
     * 用户物理删除
     * @param id
     */
    // 通过id删除用户信息
    @Delete("DELETE FROM t_user WHERE id=#{id}")
    public void deleteUser(Long id);

    /**
     * 更新用户，用户逻辑删除
     * @param user
     */
    //通过id更新用户
    public void updateUser(User user);
}
